<template>
  <tr>
    <td><input type="checkbox" v-model="item.checked" /></td>
    <td>{{ item.name }}</td>
    <td>{{ item.price }}</td>
    <td>
      <button @click="redBtn(index)">-</button>
      {{ item.num }}
      <button @click="addBtn(index)">+</button>
    </td>
    <td>{{ item.num * item.price }}</td>
    <td><button @click="delBtn(index)">删除</button></td>
  </tr>
</template>

<script>
import { mapMutations } from "vuex";
export default {
  props: ["item", "index"],
  data() {
    return {};
  },
  methods: {
    ...mapMutations(["add", "red", "del"]),
    redBtn(index) {
      this.red(index);
    },
    addBtn(index) {
      this.add(index);
    },
    delBtn(index) {
      this.del(index);
    },
  },
};
</script>

<style>
</style>